<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<!--只在模块名下面有效 -->
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>集团成员</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<div class="searchArea">
				<form id="searchBar">
					<div class="fieldset1 clearFix">
						<div class="fieldBox">
							<div class="label" style="width: 60px;">成员名称</div>
							<div class="field">
								<input name="cname" id="cname" type="text" class="ui-textbox" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label" style="width: 80px;">组织机构代码</div>
							<div class="field">
								<input name="orgCode" id="orgCode" type="text" class="ui-textbox" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">审核状态</div>
							<div class="field">
								<select name="audStsCd" id="audStsCd" data-value=" ">
									<option value=" " seleted>请选择</option>
									<option value="0" seleted>待提交</option>
									<option value="1" seleted>审核中</option>
									<option value="2" seleted>审核通过</option>
									<option value="3" seleted>审核不通过</option>
								</select>
							</div>
						</div>
						<div class="fieldBox">
							<div class="label">是否黑名单</div>
							<div class="field">
								<select name="isBlackList" id="isBlackList" data-value=" ">
									<option value=" " seleted>请选择</option>
									<option value="0" seleted>否</option>
									<option value="1" seleted>是</option>
								</select>
							</div>
						</div>
						<div class="clearFix"></div>
						<div class="btnsBox">
							<span id="searchBtn" class="sq-button sq-button-round">查询</span>
							<span id="addBlackListBtn" onclick='addBlackList()' class="sq-button sq-button-round">加入黑名单</span>
						</div>
						
					</div>
				</form>
			</div>
			<div id="ligergridDB" class="sq-grid"></div>
		</div>
	</div>
	<!--新增挂靠公司时，展示新增页面-->
<div id="div_add_black_list" style="display: none">
    <form id="div_lnk_comp_form">
        <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
            	<div class="fieldBox col_66_auto">
						<div class="label">标记类型</div>
						<div class="field">
							<select name="opTypCd" id="opTypCd" data-value=" ">
								<option value=" " seleted>请选择</option>
								<c:forEach items="${opTypCd }" var="kv">
									<option value="${kv.key }">${kv.value }</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="fieldBox col_66_auto">
						<div class="label">标记原因</div>
						<div class="field">
							<select name="signDesc" id="signDesc" data-value=" ">
								<option value=" " seleted>请选择</option>
								<c:forEach items="${signDesc }" var="kv">
									<option value="${kv.key }">${kv.value }</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="fieldBox col_100_auto">
						<div class="label">其他情况说明</div>
						<div class="field">
							<textarea name="opDesc" id="opDesc" rows="4" 
									class="l-textarea" style="width: 99%" value=""></textarea>
						</div>
					</div>
					 </div>
            <div class="clearFix"></div>
			<div class="btnsBox" align="center">
		        <span id="okBtn" onclick='savaBlackList()' class="sq-button sq-button-round">确定</span>
		        <span id="cancelBtn" onclick='cancelDiv()'  class="sq-button sq-button-round">取消</span>
		    </div>
    </form>
    
</div>
</body>
	<script type="text/javascript">
	var groupId = '${groupId}'
	var gridDB = null;
	var ligerForm = null ;
	var form = null ;
	var data2 = {};
	$(function () {
		//loadData();
		gridDB = $("#ligergridDB").ligerGrid({
			url:'<%=path%>/splGroup/relation/initMemberRelationList.do?groupId='+groupId,
           	method:'GET',
            columns: [
                { display: '成员名称', name: 'c_name', minWidth: 10 ,align:'left', enabledSort:false,},
                { display: '成员类型', name: 'type', minWidth: 50 ,align:'left', enabledSort:false},
                { display: '组织机构代码', name: 'org_code', minWidth: 50 ,align:'left', enabledSort:false}, 
                { display: '审核状态', name: 'AUD_STS_CD', minWidth: 50 ,align:'left', enabledSort:false,
                	render:function (rowdata, rowindex, value){
                		if(rowdata.AUD_STS_CD == 0){
                			return "待提交"
                		}else if(rowdata.AUD_STS_CD == 1){
                			return "审核中"
                		}else if(rowdata.AUD_STS_CD == 2){
                			return "审核通过"
                		}else if(rowdata.AUD_STS_CD == 3){
                			return "审核不通过"
                		}else if(rowdata.AUD_STS_CD == 4){
                			return "驳回呈报人"
                		}
                	}
                }, 
                { display: '是否黑名单', name: 'IS_BLACK_LIST', minWidth: 50 ,align:'left', enabledSort:false,
                	render:function (rowdata, rowindex, value){
                		if(rowdata.IS_BLACK_LIST == 1){
                			return "是"
                		}else{
                			return "否"
                		}
                	}
                }, 
                { display: '标记类型', name: 'opTypCdNm', minWidth: 50 ,align:'left', enabledSort:false},
                { display: '标记原因', name: 'signDescNm', minWidth: 50 ,align:'left', enabledSort:false},
            ],
            pageSize:10,
            pageSizeOptions: [10, 20, 30, 40, 50, 100],//按照自己的喜好选择不同的页面显示条数
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-30,
            checkbox:true,
            rownumbers:true,
            fixedCellHeight: false,
            pageParmName:'page',
            usePage:false,
            pagesizeParmName:'pageSize',
        });
		grid = liger.get("ligergridDB");
		//gridDB.setHeight(100);

		form = $("#searchBar").ligerForm();
		
		$("#searchBtn").click(function(event) {
			var form = new liger.get("searchBar");
            var data = form.getData();
            console.log(JSON.stringify(data));
            for (name in data){
                grid.setParm(name,data[name]);
            };
	        gridDB.reload();
	    });
	});
	function addBlackList(){
		var selectedRows = grid.getSelectedRows();
        if (selectedRows.length < 1) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
            return;
        }
		//$("#opTypCd").html(msg.data.opTpyCd);
    	//$("#signDesc").html(msg.data.signDesc);
		addDialog = $.ligerDialog.SQopen({
            width: 800,
            top: 100,
            title: '加入黑名单',
            target: $("#div_add_black_list")
        });
		ligerForm = $("#div_lnk_comp_form").ligerForm({
            validate: true
        });

        //清空字段值
        resetForm(ligerForm);
	}
	function resetForm(ligerForm) {
        ligerForm.setData({
        	opTypCd : "",
        	opDesc :"",
        	signDesc :""
        });
    }
	function cancelDiv(){
		//addDialog.close();
		//addDialog = null
		$.ligerDialog.hide();
		//$("#div_add_black_list").hide();
	}
	function savaBlackList(){
		//alert(1)
		var data = ligerForm.getData();
		var _splIds = [];
		var _lnkIds = [];
		var selectedRows = grid.getSelectedRows();
        for(i = 0 ; i<selectedRows.length; i++){
        	if(selectedRows[i].type == '挂靠公司'){
        		_lnkIds.push(selectedRows[i].LNK_COMP_ID)
        	}else if(selectedRows[i].type == '供应商'){
        		_splIds.push(selectedRows[i].SPL_ID)
        	}
        }
		data["splIds"] = JSON.stringify(_splIds) ;
		data["lnkIds"] = JSON.stringify(_lnkIds) ;
		data["isWarn"] = 1;
        $.ajax({
        	 type: 'post',
             dataType: 'json',
             data: data,
             url: '<%=path%>/spl/splRelOpLog/addAll.do',
             beforeSend: function () {
                 wait_dialog = $.ligerDialog.SQalert({
                     content: LogUtils.LOG_CMM_DATA_LOADING,
                     SQ_type: "waitting"
                 });
             },
             success: function (msg) {
                 wait_dialog.close();
                 if (msg.success == 1) {
                     $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                     $.ligerDialog.hide();
                     gridDB.reload();
                 } else {
                     $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                 }
             }
        })
	}
	
</script>


</html>
